package com.wash.shoes.common.enums;

import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import lombok.Getter;

/**
 * 渠道: DY,MT,WEIXIN
 */
@Getter
public enum ChannelEnum {

    DY("抖音", "DY"), MT("美团", "MT"), WEIXIN("微信", "WEIXIN");

    @JsonValue
    private String name;
    @EnumValue
    private String code;

    ChannelEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    @JsonCreator
    public static ChannelEnum create(String code) {
        for (ChannelEnum value : ChannelEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    public Map<String, String> getMap() {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        map.put("code", code);
        return map;
    }
}
